package com.ruyixing.shopmanager.utils;

import android.content.Context;
import android.location.LocationManager;

import com.baidu.location.LocationClientOption;

public class LocationUtils {
	public static boolean isGpsAvailable(Context context) {
		String[] mConfigurableProviders = { LocationManager.GPS_PROVIDER,
				LocationManager.NETWORK_PROVIDER };
		LocationManager locationMgr = (LocationManager) context
				.getSystemService(Context.LOCATION_SERVICE);
		if (mConfigurableProviders != null && locationMgr != null) {
			for (String provider : mConfigurableProviders) {
				if (locationMgr.isProviderEnabled(provider)) {
					if (provider == LocationManager.NETWORK_PROVIDER) {
						if (NetworkUtils.isNetworkConnected(context)) {
							return true;
						}
					} else {
						return true;
					}
				}
			}
		}
		return false;
	}

	public static LocationClientOption getDefaultOption() {
		LocationClientOption option = new LocationClientOption();
		option.setOpenGps(true);
		option.setAddrType("all");// 返回的定位结果包含地址信息
		option.setCoorType("gcj02");// 返回的定位结果是百度经纬度,默认值gcj02
		option.setScanSpan(5000);// 设置发起定位请求的间隔时间为5000ms
		option.disableCache(true);// 禁止启用缓存定位
		option.setPoiNumber(5); // 最多返回POI个数
		option.setPoiDistance(1000); // poi查询距离
		option.setPoiExtraInfo(true); // 是否需要POI的电话和地址等详细信息
		return option;
	}
}
